package day04;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/18
 */
public class Test04 {
    public static void main(String[] args) {
        char[][] poem = {
                {'床', '前', '明', '月', '光'},
                {'疑', '是', '地', '上', '霜'},
                {'举', '头', '望', '明', '月'},
                {'低', '头', '思', '故', '乡'}
        };
//        int[][] arr={{1,2,3},{4,5,6},{7,8,9}};
//        for (int i = 0; i < arr.length; i++) {
//            System.out.println(arr[i]);
//        }
        // 打印原始数组
        System.out.println("原始的诗：");
        for (int i = 0; i < poem.length; i++) {
            System.out.println(poem[i]);
        }

        int rows = poem.length;          // 原行数 4
        int cols = poem[0].length;       // 原列数 5
        char[][] transposed = new char[cols][rows];  // 转置后 5行4列

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                transposed[j][rows-i-1] = poem[i][j];
            }
        }
        System.out.println("\n转变后的诗：");
        for (int i = 0; i < transposed.length; i++) {
            System.out.println(transposed[i]);
        }
    }
}



